home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / applications / wp / textra16.lha / Textra116 / Scripts / JForth_Scripts / jfcomment.textra < prev    next >
Encoding:
Text File  |  1994-04-05  |  2.2 KB  |  89 lines

  1.      /******************************************************************
  2.      *   TEXTRA AREXX script -- Mike Haas, 1991, All Rights Reserved.  *
  3.      * Freely distributable ONLY as a component of the TEXTRA package. *
  4.      * This banner may not be removed or altered (improvements to the  *
  5.      *    actual program welcome).  Please document and send to me.    *
  6.      *        !!! PLACE THIS FILE IN YOUR REXX: DIRECTORY !!!          *
  7.      ******************************************************************/
  8.  
  9. /*
  10. ** JFComment.textra   Mike Haas
  11. **
  12. ** Convienient for commenting out sections of code in Forth or assembler
  13. **
  14. ** Just select some lines of text and enter:   JFComment
  15. **
  16. ** If the lines WERE commented out by a leading '\ ', it will be stripped.
  17. ** If they weren't, they are now!
  18. **
  19. ** note, you can enter a character such as...  JFComment *
  20. **
  21. ** and the program will add that, plus a space at the start of
  22. ** each line.  (It just uses '\' as a default)
  23. */
  24.  
  25. /* 00001 mdh 20-nov-92  check version (cause of 'CheckCancel') */
  26. /* 00002 mdh 04-apr-94  no longer need selection, comment curs line */
  27.  
  28. OPTIONS results
  29.  
  30. rex = 0; result = "NOTSUPPORTED"    /*00001*/
  31. textraversion
  32. parse var result maj min rex
  33. if (result == "NOTSUPPORTED") | (rex < 3) then do
  34.     notify "Textra V1.13 or later required for this script."
  35.     exit
  36. end
  37.  
  38. parse arg thechar
  39.  
  40. if (thechar == "") then
  41.    thechar = "\"
  42.  
  43. get select position
  44.  
  45. if (result == "NO SELECT") then do   /* is nothing selected? */
  46.  
  47.     get cursor position   /*00002 */
  48.     parse var result   startx' 'starty
  49.     endx = 0
  50.     endy = starty + 1
  51.  
  52. end
  53. else
  54.  
  55.     /* yes, there is a selection, get it's boundaries */
  56.     parse var result   startx ' ' starty ' ' endx ' ' endy
  57.  
  58. currx = startx
  59. curry = starty
  60.  
  61. /* if nothing on the endline is actually selected, don't include it */
  62. if (endx == 0) then  endy = endy - 1
  63.  
  64.  
  65.  
  66. do while (curry <= endy)
  67.  
  68.     CheckCancel; if (result == CANCEL) then exit
  69.  
  70.     do
  71.     
  72.        gotoxy 0 curry;   get cursor char
  73.        if (result == thechar) then do
  74.           del
  75.           get cursor char
  76.           if ((result == " ") | (result == "    ")) then do
  77.              del
  78.           end
  79.        end
  80.        else do
  81.           text thechar" ";
  82.        end
  83.        
  84.        curry = curry + 1
  85.     end
  86.  
  87. end
  88.           
  89.